package common.test;


public class Module{
	private String moduleName;
	private VersionNumber versionNumber;
	private String moduleFilename;
	private String updateLocation;
	private String checksumType;
	private String checksumValue;	

	public String getChecksumType(){
		return checksumType;
	}

	public void setChecksumType(String checksumType){
		this.checksumType = checksumType;
	}

	public String getChecksumValue(){
		return checksumValue;
	}

	public void setChecksumValue(String checksumValue){
		this.checksumValue = checksumValue;
	}

	public Module(String moduleName, VersionNumber versionNumber, String moduleFilename, String updateLocation){
		super();
		this.moduleName = moduleName;
		this.versionNumber = versionNumber;
		this.moduleFilename = moduleFilename;
		this.updateLocation = updateLocation;
	}

	public Module(String moduleName, VersionNumber versionNumber, String moduleFilename){
		super();
		this.moduleName = moduleName;
		this.versionNumber = versionNumber;
		this.moduleFilename = moduleFilename;
	}

	public String getModuleFilename(){
		return moduleFilename;
	}

	public String getUpdateLocation(){
		return updateLocation;
	}

	public VersionNumber getVersionNumber(){
		return versionNumber;
	}

	/**
	 * Compare two module versions
	 * return > 0 if this module is a newer version than parameter module
	 * return < 0 if this module is an older version than parameter module
	 * return 0 if this module is the same version as parameter module
	 * 
	 * @param module
	 * @return
	 */
	public int compareTo(Module module){
		return this.getVersionNumber().compareTo(module.getVersionNumber());
	}

	@Override
	public String toString(){
		StringBuffer strBuf = new StringBuffer();
		strBuf.append(getVersionNumber());
		strBuf.append(" | ");
		strBuf.append(getModuleFilename());
		strBuf.append(" | ");
		strBuf.append(getUpdateLocation());
		strBuf.append(" | ");
		strBuf.append(getChecksumType());
		strBuf.append(":");
		strBuf.append(getChecksumValue());
		
		return strBuf.toString();
	}

	public String getModuleName(){
		return moduleName;
	}
	
	public void incrementVersion(String releaseLevel){
		versionNumber.incrementVersion(releaseLevel);
	}
}
